import request from '@/utils/request'

export function getled(params) {
  return request({
    url: 'material/led_home',
    method: 'get',
    params
  })
}

export function getDetail(params) {
  return request({
    url: 'material/led_home/detail',
    method: 'get',
    params
  })
}

export function deleteDash(params) {
  return request({
    url: 'material/led_home',
    method: 'DELETE',
    params
  })
}

export function playDash(params) {
  return request({
    url: 'material/led_home/play',
    method: 'post',
    params
  })
}

export function dashboardHandle(data, id) {
  return request({
    url: 'material/led_home',
    method: id ? 'put' : 'post',
    data
  })
}
export function screenShow() {
  return request({
    url: 'material/led_home/current_show',
    method: 'get'
  })
}
// 详情面板
export function getpanel(params) {
  return request({
    url: 'material/led_detail',
    method: 'get',
    params
  })
}

export function screenDetail(params) {
  return request({
    url: 'material/led_detail/detail',
    method: 'get',
    params
  })
}

export function deletePanel(params) {
  return request({
    url: 'material/led_detail',
    method: 'DELETE',
    params
  })
}

export function panelHandle(data, id) {
  return request({
    url: 'material/led_detail',
    method: id ? 'put' : 'post',
    data
  })
}

export function uploadfile(data) {
  return request({
    url: 'basic/sissfile/upload/file',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

export function getdict() {
  return request({
    url: 'basic/sissdictitem/get/list',
    method: 'get'
  })
}
export function getDictByCode(data, code) {
  var ret = []
  data.forEach(function(v) {
    if (v[code]) {
      ret = v[code]
    }
  })
  return ret
}
